/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NuevaCotizacion.java
 *
 * Created on Dec 25, 2008, 9:10:02 PM
 */
package interfaz;

import dominio.*;
import integracion.*;
import java.awt.Color;
import java.awt.Component;
import java.io.IOException;
import java.sql.Date;
import java.sql.SQLException;
import java.sql.Time;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

/**
 *
 * @author Maya
 */
public class NuevaCotizacion extends javax.swing.JFrame {

    ControlUso controlUso;
    ControlInsumo controlInsumo;
    ControlCategoria controlCategoria;
    ControlInsumoInventario controlInsumoInventario;
    ControlClienteParticular controlClientePart;
    ControlClienteCompania controlClienteComp;
    ControlEmpleado controlEmpleado;
    ControlEvento controlEvento;
    ControlCotizacion controlCotizacion;
    ControlEmpleadoClientePart controlEmpleadoClientePart;
    ControlEmpleadoClienteComp controlEmpleadoClienteComp;
    ControlConsultaInsumos controlConsultaInsumos;
    private Component aviso;

    /** Creates new form NuevaCotizacion */
    @SuppressWarnings("static-access")
    public NuevaCotizacion() throws SQLException {
        initComponents();
        this.setLocation(125, 5);
        List<Insumo> insumos = this.consultarInsumos();
        this.cargarTablaCotizaciones(insumos);
        this.cargarCedulasEjecutivos();
        this.validarCampos();
        this.jLabelCOT.setVisible(false);
        this.jLabelCOT2.setVisible(false);
        this.setMinSelectableDate();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroupEstatus = new javax.swing.ButtonGroup();
        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel6 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        direccion = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        telefono = new javax.swing.JTextField();
        clienteCed = new javax.swing.JTextField();
        listaCotizaciones = new java.awt.List();
        jLabel14 = new javax.swing.JLabel();
        clienteRif = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        radioCedula = new javax.swing.JRadioButton();
        radioRif = new javax.swing.JRadioButton();
        jLabel16 = new javax.swing.JLabel();
        checkLista = new javax.swing.JCheckBox();
        jLabel75 = new javax.swing.JLabel();
        jComboBoxSexo = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        nombre = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        apellido = new javax.swing.JTextField();
        jLabel76 = new javax.swing.JLabel();
        jDateChooserNac = new com.toedter.calendar.JDateChooser();
        jPanel2 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        color = new javax.swing.JTextField();
        jLabel47 = new javax.swing.JLabel();
        horaInicioEvento = new javax.swing.JComboBox();
        jLabel48 = new javax.swing.JLabel();
        horaFinEvento = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        motivo = new javax.swing.JTextField();
        fechaEvento = new com.toedter.calendar.JDateChooser();
        jLabel19 = new javax.swing.JLabel();
        jTextFieldLugar = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        saldo = new javax.swing.JLabel();
        abono = new javax.swing.JLabel();
        total = new javax.swing.JLabel();
        deposito = new javax.swing.JLabel();
        iva = new javax.swing.JLabel();
        subtotal = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        jLabelCOT = new javax.swing.JLabel();
        jLabelCOT2 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel8 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tablaCotizacion = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tablaCotizacion1 = new javax.swing.JTable();
        jButton2 = new javax.swing.JButton();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jPanel10 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tablaCotizacion2 = new javax.swing.JTable();
        jButton4 = new javax.swing.JButton();
        jPanel11 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        tablaCotizacion3 = new javax.swing.JTable();
        jButton5 = new javax.swing.JButton();
        jPanel12 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tablaCotizacion4 = new javax.swing.JTable();
        jButton6 = new javax.swing.JButton();
        jPanel13 = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        tablaCotizacion5 = new javax.swing.JTable();
        jButton7 = new javax.swing.JButton();
        jPanel14 = new javax.swing.JPanel();
        jScrollPane7 = new javax.swing.JScrollPane();
        tablaCotizacion6 = new javax.swing.JTable();
        jButton8 = new javax.swing.JButton();
        jPanel15 = new javax.swing.JPanel();
        jScrollPane8 = new javax.swing.JScrollPane();
        tablaCotizacion7 = new javax.swing.JTable();
        jButton9 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel51 = new javax.swing.JLabel();
        cedulaEjecutivo = new javax.swing.JComboBox();
        jButton10 = new javax.swing.JButton();
        cancelar = new javax.swing.JButton();
        procesar = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        archivo = new javax.swing.JMenu();
        nuevaCotizacion = new javax.swing.JMenuItem();
        informacionSistema = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JSeparator();
        exit = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();

        setTitle("Nueva Cotizacion");

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "COTIZACION", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11), new java.awt.Color(0, 102, 204))); // NOI18N
        jPanel6.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 12));

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos del Cliente", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N

        jLabel3.setText("Domicilio Fiscal:");

        jLabel8.setText("Telefono:");

        clienteCed.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clienteCedActionPerformed(evt);
            }
        });
        clienteCed.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                clienteCedKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                clienteCedKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                clienteCedKeyTyped(evt);
            }
        });

        listaCotizaciones.setEnabled(false);
        listaCotizaciones.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                listaCotizacionesMouseClicked(evt);
            }
        });

        jLabel14.setText("Rif:");
        jLabel14.setEnabled(false);

        clienteRif.setEnabled(false);
        clienteRif.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clienteRifActionPerformed(evt);
            }
        });
        clienteRif.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                clienteRifKeyReleased(evt);
            }
        });

        jLabel15.setText("CI");

        buttonGroup1.add(radioCedula);
        radioCedula.setSelected(true);
        radioCedula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioCedulaActionPerformed(evt);
            }
        });

        buttonGroup1.add(radioRif);
        radioRif.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioRifActionPerformed(evt);
            }
        });

        jLabel16.setForeground(new java.awt.Color(51, 0, 255));
        jLabel16.setText("Este cliente ha cotizado:");

        checkLista.setEnabled(false);
        checkLista.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkListaActionPerformed(evt);
            }
        });

        jLabel75.setText("Sexo:");

        jComboBoxSexo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "F", "M" }));

        jLabel1.setText("Nombre o Razon Social:");

        nombre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nombreActionPerformed(evt);
            }
        });

        jLabel2.setText("Apellido:");

        jLabel76.setText("Fecha Nacimiento:");

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(radioCedula)
                            .add(radioRif))
                        .add(15, 15, 15)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 88, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel3)
                            .add(jLabel75)
                            .add(jLabel2)
                            .add(jLabel1)
                            .add(jLabel76)
                            .add(jLabel14)
                            .add(jLabel15))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(telefono, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                            .add(direccion, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                            .add(apellido, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                            .add(nombre, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                            .add(jDateChooserNac, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 119, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(clienteRif, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                            .add(clienteCed, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 152, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jComboBoxSexo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(6, 6, 6)
                        .add(checkLista)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 133, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(listaCotizaciones, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 263, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(35, 35, 35)))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(new java.awt.Component[] {jLabel1, jLabel14, jLabel15, jLabel2, jLabel3, jLabel75, jLabel76, jLabel8}, org.jdesktop.layout.GroupLayout.HORIZONTAL);

        jPanel1Layout.linkSize(new java.awt.Component[] {apellido, clienteCed, clienteRif, direccion, jDateChooserNac, nombre, telefono}, org.jdesktop.layout.GroupLayout.HORIZONTAL);

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(clienteCed, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(radioCedula)
                    .add(jLabel15))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(clienteRif, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(radioRif)
                    .add(jLabel14))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jLabel76)
                    .add(jDateChooserNac, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel1)
                    .add(nombre, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel2)
                    .add(apellido, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel75)
                    .add(jComboBoxSexo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel3)
                    .add(direccion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel8)
                    .add(telefono, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jLabel16)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(checkLista)
                    .add(listaCotizaciones, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel1Layout.linkSize(new java.awt.Component[] {apellido, direccion, nombre, telefono}, org.jdesktop.layout.GroupLayout.VERTICAL);

        jPanel1Layout.linkSize(new java.awt.Component[] {clienteCed, clienteRif, jLabel1, jLabel14, jLabel15, jLabel2, jLabel3, jLabel8, radioCedula, radioRif}, org.jdesktop.layout.GroupLayout.VERTICAL);

        jPanel1Layout.linkSize(new java.awt.Component[] {jComboBoxSexo, jLabel75}, org.jdesktop.layout.GroupLayout.VERTICAL);

        jPanel1Layout.linkSize(new java.awt.Component[] {jDateChooserNac, jLabel76}, org.jdesktop.layout.GroupLayout.VERTICAL);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos del Evento", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N

        jLabel6.setText("Fecha del Evento:");

        jLabel4.setText("Color de la Decoracion:");

        jLabel47.setText("Hora Inicio:");

        horaInicioEvento.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "00:00:00", "01:00:00", "02:00:00", "03:00:00", "04:00:00", "05:00:00", "06:00:00", "07:00:00", "08:00:00", "09:00:00", "10:00:00", "11:00:00", "12:00:00", "13:00:00", "14:00:00", "15:00:00", "16:00:00", "17:00:00", "18:00:00", "19:00:00", "20:00:00", "21:00:00", "22:00:00", "23:00:00" }));
        horaInicioEvento.setPreferredSize(new java.awt.Dimension(68, 20));

        jLabel48.setText("Hora Fin:");

        horaFinEvento.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "00:00:00", "01:00:00", "02:00:00", "03:00:00", "04:00:00", "05:00:00", "06:00:00", "07:00:00", "08:00:00", "09:00:00", "10:00:00", "11:00:00", "12:00:00", "13:00:00", "14:00:00", "15:00:00", "16:00:00", "17:00:00", "18:00:00", "19:00:00", "20:00:00", "21:00:00", "22:00:00", "23:00:00" }));
        horaFinEvento.setPreferredSize(new java.awt.Dimension(68, 20));

        jLabel7.setText("Motivo:");

        jLabel19.setText("Lugar:");

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2Layout.createSequentialGroup()
                .add(39, 39, 39)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 101, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel48, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)
                    .add(jLabel47, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)
                    .add(jLabel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 111, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 111, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel6))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(horaFinEvento, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 148, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(horaInicioEvento, 0, 148, Short.MAX_VALUE)
                    .add(motivo, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                    .add(color, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                    .add(jTextFieldLugar, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                    .add(fechaEvento, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 134, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(33, 33, 33))
        );

        jPanel2Layout.linkSize(new java.awt.Component[] {color, fechaEvento, horaFinEvento, horaInicioEvento, jTextFieldLugar, motivo}, org.jdesktop.layout.GroupLayout.HORIZONTAL);

        jPanel2Layout.linkSize(new java.awt.Component[] {jLabel19, jLabel4, jLabel47, jLabel48, jLabel6, jLabel7}, org.jdesktop.layout.GroupLayout.HORIZONTAL);

        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel6)
                    .add(fechaEvento, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jTextFieldLugar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(color, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(motivo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(horaInicioEvento, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel47))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(horaFinEvento, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel48))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2Layout.linkSize(new java.awt.Component[] {color, horaFinEvento, horaInicioEvento, motivo}, org.jdesktop.layout.GroupLayout.VERTICAL);

        jPanel2Layout.linkSize(new java.awt.Component[] {fechaEvento, jLabel19, jLabel4, jLabel47, jLabel48, jLabel6, jLabel7}, org.jdesktop.layout.GroupLayout.VERTICAL);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Detalles"));

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 10));
        jLabel5.setText("Sub - TOTAL BsF.");

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 10));
        jLabel9.setText("IVA 9% BsF.");

        jLabel13.setFont(new java.awt.Font("Tahoma", 0, 10));
        jLabel13.setText("5% Deposito por Averias BsF.");

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 10));
        jLabel11.setText("TOTAL BsF.");

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 10));
        jLabel10.setText("ABONO 50% BsF.");

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 10));
        jLabel12.setForeground(new java.awt.Color(255, 0, 0));
        jLabel12.setText("SALDO BsF.");

        saldo.setFont(new java.awt.Font("Tahoma", 0, 10));
        saldo.setForeground(new java.awt.Color(255, 0, 0));
        saldo.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        saldo.setText("0.0");

        abono.setFont(new java.awt.Font("Tahoma", 0, 10));
        abono.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        abono.setText("0.0");

        total.setFont(new java.awt.Font("Tahoma", 1, 10));
        total.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        total.setText("0.0");

        deposito.setFont(new java.awt.Font("Tahoma", 0, 10));
        deposito.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        deposito.setText("0.0");

        iva.setFont(new java.awt.Font("Tahoma", 0, 10));
        iva.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        iva.setText("0.0");

        subtotal.setFont(new java.awt.Font("Tahoma", 0, 10));
        subtotal.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        subtotal.setText("0.0");
        subtotal.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/refresh.png"))); // NOI18N
        jButton3.setText("Limpiar todo");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jLabelCOT.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelCOT.setText("ESTATUS DE LA COTIZACION:");

        jLabelCOT2.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelCOT2.setText("estatus");

        org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jButton3)
                    .add(jLabelCOT)
                    .add(jLabelCOT2))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 165, Short.MAX_VALUE)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
                        .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel12)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel5)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel9)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel11)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel13))
                        .add(102, 102, 102)
                        .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(total, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(deposito)
                            .add(saldo)
                            .add(iva)
                            .add(subtotal, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 82, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
                        .add(jLabel10)
                        .add(102, 102, 102)
                        .add(abono)))
                .addContainerGap())
        );

        jPanel5Layout.linkSize(new java.awt.Component[] {abono, deposito, iva, saldo, subtotal, total}, org.jdesktop.layout.GroupLayout.HORIZONTAL);

        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel5)
                    .add(subtotal))
                .add(5, 5, 5)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel9)
                    .add(iva))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel13)
                    .add(deposito))
                .add(18, 18, 18)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(total)
                    .add(jLabel11))
                .add(16, 16, 16)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jLabel10)
                    .add(abono))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel12)
                    .add(saldo)))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabelCOT)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabelCOT2)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 48, Short.MAX_VALUE)
                .add(jButton3)
                .add(11, 11, 11))
        );

        jPanel5Layout.linkSize(new java.awt.Component[] {abono, deposito, iva, saldo, subtotal, total}, org.jdesktop.layout.GroupLayout.VERTICAL);

        tablaCotizacion.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Cantidad", "Concepto", "Costo Unitario", "Total"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaCotizacion.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        tablaCotizacion.getTableHeader().setReorderingAllowed(false);
        tablaCotizacion.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tablaCotizacionMouseClicked(evt);
            }
        });
        tablaCotizacion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tablaCotizacionKeyPressed(evt);
            }
        });
        jScrollPane1.setViewportView(tablaCotizacion);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/refresh.png"))); // NOI18N
        jButton1.setText("Limpiar Tabla");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel8Layout = new org.jdesktop.layout.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 637, Short.MAX_VALUE)
                    .add(jButton1))
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                .add(8, 8, 8)
                .add(jButton1)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Festejos", jPanel8);

        tablaCotizacion1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Cantidad", "Concepto", "Costo Unitario", "Total"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaCotizacion1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        tablaCotizacion1.getTableHeader().setReorderingAllowed(false);
        tablaCotizacion1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tablaCotizacion1KeyPressed(evt);
            }
        });
        tablaCotizacion1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tablaCotizacion1MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tablaCotizacion1);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/refresh.png"))); // NOI18N
        jButton2.setText("Limpiar Tabla");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel17.setText("NOTA: en la recreacion, el total sera la cantidad*costoUnitario*horas evento; a excepcion de los fuegos");

        jLabel18.setText("artificiales");

        org.jdesktop.layout.GroupLayout jPanel9Layout = new org.jdesktop.layout.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 637, Short.MAX_VALUE)
                    .add(jPanel9Layout.createSequentialGroup()
                        .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel17)
                            .add(jPanel9Layout.createSequentialGroup()
                                .add(35, 35, 35)
                                .add(jLabel18)))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 22, Short.MAX_VALUE)
                        .add(jButton2)))
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jButton2)
                    .add(jPanel9Layout.createSequentialGroup()
                        .add(jLabel17)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel18)))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Recreacion", jPanel9);

        tablaCotizacion2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Cantidad", "Concepto", "Costo Unitario", "Total"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaCotizacion2.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        tablaCotizacion2.getTableHeader().setReorderingAllowed(false);
        tablaCotizacion2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tablaCotizacion2KeyPressed(evt);
            }
        });
        tablaCotizacion2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tablaCotizacion2MouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(tablaCotizacion2);

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/refresh.png"))); // NOI18N
        jButton4.setText("Limpiar Tabla");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel10Layout = new org.jdesktop.layout.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jButton4)
                    .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 637, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                .add(8, 8, 8)
                .add(jButton4)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Servicios", jPanel10);

        tablaCotizacion3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Cantidad", "Concepto", "Costo Unitario", "Total"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaCotizacion3.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        tablaCotizacion3.getTableHeader().setReorderingAllowed(false);
        tablaCotizacion3.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tablaCotizacion3KeyPressed(evt);
            }
        });
        tablaCotizacion3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tablaCotizacion3MouseClicked(evt);
            }
        });
        jScrollPane4.setViewportView(tablaCotizacion3);

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/refresh.png"))); // NOI18N
        jButton5.setText("Limpiar Tabla");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel11Layout = new org.jdesktop.layout.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jButton5)
                    .add(jScrollPane4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 637, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton5)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Decoracion", jPanel11);

        tablaCotizacion4.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Cantidad", "Concepto", "Costo Unitario", "Total"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaCotizacion4.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        tablaCotizacion4.getTableHeader().setReorderingAllowed(false);
        tablaCotizacion4.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tablaCotizacion4KeyPressed(evt);
            }
        });
        tablaCotizacion4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tablaCotizacion4MouseClicked(evt);
            }
        });
        jScrollPane5.setViewportView(tablaCotizacion4);

        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/refresh.png"))); // NOI18N
        jButton6.setText("Limpiar Tabla");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel12Layout = new org.jdesktop.layout.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel12Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jButton6)
                    .add(jScrollPane5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 637, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton6)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Comestibles", jPanel12);

        tablaCotizacion5.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Cantidad", "Concepto", "Costo Unitario", "Total"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaCotizacion5.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        tablaCotizacion5.getTableHeader().setReorderingAllowed(false);
        tablaCotizacion5.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tablaCotizacion5KeyPressed(evt);
            }
        });
        tablaCotizacion5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tablaCotizacion5MouseClicked(evt);
            }
        });
        jScrollPane6.setViewportView(tablaCotizacion5);

        jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/refresh.png"))); // NOI18N
        jButton7.setText("Limpiar Tabla");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel13Layout = new org.jdesktop.layout.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel13Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jButton7)
                    .add(jScrollPane6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 637, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton7)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Carritos de Consumos", jPanel13);

        tablaCotizacion6.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Cantidad", "Concepto", "Costo Unitario", "Total"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaCotizacion6.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        tablaCotizacion6.getTableHeader().setReorderingAllowed(false);
        tablaCotizacion6.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tablaCotizacion6KeyPressed(evt);
            }
        });
        tablaCotizacion6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tablaCotizacion6MouseClicked(evt);
            }
        });
        jScrollPane7.setViewportView(tablaCotizacion6);

        jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/refresh.png"))); // NOI18N
        jButton8.setText("Limpiar Tabla");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel14Layout = new org.jdesktop.layout.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel14Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jButton8)
                    .add(jScrollPane7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 637, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton8)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Pasapalos", jPanel14);

        tablaCotizacion7.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Cantidad", "Concepto", "Costo Unitario", "Total"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaCotizacion7.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        tablaCotizacion7.getTableHeader().setReorderingAllowed(false);
        tablaCotizacion7.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tablaCotizacion7KeyPressed(evt);
            }
        });
        tablaCotizacion7.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tablaCotizacion7MouseClicked(evt);
            }
        });
        jScrollPane8.setViewportView(tablaCotizacion7);

        jButton9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/refresh.png"))); // NOI18N
        jButton9.setText("Limpiar Tabla");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel15Layout = new org.jdesktop.layout.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel15Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jButton9)
                    .add(jScrollPane8, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 637, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane8, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton9)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Transporte", jPanel15);

        org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 662, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 463, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(9, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Atendido por el Ejecutivo", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N

        jLabel51.setText("Nombre:");

        cedulaEjecutivo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cedulaEjecutivoActionPerformed(evt);
            }
        });

        jButton10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/search.png"))); // NOI18N
        jButton10.setText("Disponible");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel51)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(cedulaEjecutivo, 0, 163, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 101, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel51)
                    .add(cedulaEjecutivo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jButton10))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3Layout.linkSize(new java.awt.Component[] {cedulaEjecutivo, jLabel51}, org.jdesktop.layout.GroupLayout.VERTICAL);

        org.jdesktop.layout.GroupLayout jPanel6Layout = new org.jdesktop.layout.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 346, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel6Layout.createSequentialGroup()
                .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel4, 0, 634, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel6Layout.createSequentialGroup()
                        .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );

        cancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/cancel.png"))); // NOI18N
        cancelar.setText("Cancelar");
        cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelarActionPerformed(evt);
            }
        });

        procesar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/edit_add_1.png"))); // NOI18N
        procesar.setText("Agregar");
        procesar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                procesarActionPerformed(evt);
            }
        });

        archivo.setText("Archivo");

        nuevaCotizacion.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
        nuevaCotizacion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/add.png"))); // NOI18N
        nuevaCotizacion.setText("Nueva Cotizacion...");
        nuevaCotizacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nuevaCotizacionActionPerformed(evt);
            }
        });
        archivo.add(nuevaCotizacion);

        informacionSistema.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.CTRL_MASK));
        informacionSistema.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/database.png"))); // NOI18N
        informacionSistema.setText("Informacion del Sistema...");
        informacionSistema.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                informacionSistemaActionPerformed(evt);
            }
        });
        archivo.add(informacionSistema);
        archivo.add(jSeparator1);

        exit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
        exit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/exit.png"))); // NOI18N
        exit.setText("Salir");
        exit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitActionPerformed(evt);
            }
        });
        archivo.add(exit);

        jMenuBar1.add(archivo);

        jMenu1.setText("Ayuda");

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/info.png"))); // NOI18N
        jMenuItem1.setText("Acerca de MDJ");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap(897, Short.MAX_VALUE)
                .add(procesar)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(cancelar)
                .addContainerGap())
        );

        layout.linkSize(new java.awt.Component[] {cancelar, procesar}, org.jdesktop.layout.GroupLayout.HORIZONTAL);

        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(jPanel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(cancelar)
                    .add(procesar))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        layout.linkSize(new java.awt.Component[] {cancelar, procesar}, org.jdesktop.layout.GroupLayout.VERTICAL);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void nuevaCotizacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nuevaCotizacionActionPerformed
        NuevaCotizacion cot = null;
        try {
            cot = new NuevaCotizacion();
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
        cot.setVisible(true);
        this.setVisible(false);
}//GEN-LAST:event_nuevaCotizacionActionPerformed

    private void informacionSistemaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_informacionSistemaActionPerformed
        Informacion info = new Informacion();
        info.setVisible(true);
        this.setVisible(false);
}//GEN-LAST:event_informacionSistemaActionPerformed

    private void exitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitActionPerformed
        int resultado = JOptionPane.showConfirmDialog(null, "Esta seguro que desea salir del sistema?", "ATENCION", JOptionPane.OK_CANCEL_OPTION);
        if (resultado == 0) {
            System.exit(0);
        }
}//GEN-LAST:event_exitActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        About ab = new About();
        ab.setVisible(true);
}//GEN-LAST:event_jMenuItem1ActionPerformed

    private void nombreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nombreActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_nombreActionPerformed

    private void clienteCedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clienteCedActionPerformed
}//GEN-LAST:event_clienteCedActionPerformed

    private void cedulaEjecutivoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cedulaEjecutivoActionPerformed
}//GEN-LAST:event_cedulaEjecutivoActionPerformed

    private void tablaCotizacionKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tablaCotizacionKeyPressed
        this.calcularMontoTotal(tablaCotizacion);
    }//GEN-LAST:event_tablaCotizacionKeyPressed

    private void tablaCotizacionMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaCotizacionMouseClicked
        this.calcularMontoTotal(tablaCotizacion);
    }//GEN-LAST:event_tablaCotizacionMouseClicked

    private void procesarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_procesarActionPerformed
        boolean resultado = this.isTablaVacia();
        boolean flag = this.isCamposCompletos();
        if (!(flag) || resultado == true) {
            JOptionPane.showMessageDialog(aviso, "Debe llenar todos los campos: datos e insumos. ", "Aviso", 1);
        } else {
            if (flag && !resultado) {
                if(this.esMasDeUnMesDiferencia()){
                    JOptionPane.showMessageDialog(aviso, "Los precios estan sujetos a cambios \n" +
                            "sin previo aviso. ", "Aviso", 1);
                }
                boolean existe = this.existeCliente();
                if (existe) {
                    this.insertarEventoCotizacion();
                    this.insertarUSO();
                } else {
                    this.insertarClienteEventoCotizacion();
                    this.insertarUSO();
                }
            }
        }
}//GEN-LAST:event_procesarActionPerformed

    private void setMinSelectableDate(){
        java.sql.Date now = new java.sql.Date(System.currentTimeMillis());
        long diff = (15*1000*60*60*24);
        long fecha_getTime = diff + now.getTime();
        this.fechaEvento.setMinSelectableDate(new java.sql.Date(fecha_getTime));
    }

    private boolean esMasDeUnMesDiferencia() {
        boolean result = false;
        java.sql.Date FechaEvento = new java.sql.Date(fechaEvento.getDate().getTime());
        java.sql.Date now = new java.sql.Date(System.currentTimeMillis());

        long diff = FechaEvento.getTime() - now.getTime();
        long dias = 0;

        if (FechaEvento.equals(now)) {
            dias = 0;
        } else {
            dias = (diff / (1000 * 60 * 60 * 24)) + 1;
        }
        if(dias>30){
            result = true;
            return result;
        }
        return result;
    }

    private void insertarUSO() {
        try {
            this.insertarUSO(tablaCotizacion);
            this.insertarUSO(tablaCotizacion1);
            this.insertarUSO(tablaCotizacion2);
            this.insertarUSO(tablaCotizacion3);
            this.insertarUSO(tablaCotizacion4);
            this.insertarUSO(tablaCotizacion5);
            this.insertarUSO(tablaCotizacion6);
            this.insertarUSO(tablaCotizacion7);

        } catch (IOException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void insertarUSO(JTable tablaCotizacion) throws IOException, SQLException {
        controlUso = new ControlUso();
        controlEvento = new ControlEvento();
        List<Evento> eventos = controlEvento.consultarEventos();

        for (int i = 0; i < tablaCotizacion.getRowCount(); i++) {
            int cantidad = Integer.parseInt(tablaCotizacion.getValueAt(i, 0).toString());
            String[] value = tablaCotizacion.getValueAt(i, 1).toString().split(", ");
            int idInsumo = Integer.parseInt(value[0]);
            Integer idUltimoEvento = eventos.get(eventos.size() - 1).getIdEvento();

            if (cantidad > 0) {
                Uso uso = new Uso(false, idInsumo, idUltimoEvento, null, cantidad);
                boolean result = controlUso.agregarUso(uso);
            }
        }

    }

    private void insertarClienteEventoCotizacion() {
        boolean resultCliente = this.insertarCliente();
        if (resultCliente) {
            boolean resultEvento = this.insertarEvento();
            if (resultEvento) {
                boolean resultCotizacion = this.insertarCotizacion();
                if (resultCotizacion) {
                    JOptionPane.showMessageDialog(null, "La cotizacion ha sido procesada con Exito", "Resultado", JOptionPane.INFORMATION_MESSAGE);
                } else {
                    this.borrarEvento();
                    JOptionPane.showMessageDialog(null, "La cotizacion no pudo ser procesada", "Resultado", JOptionPane.ERROR_MESSAGE);
                }
            } else {
                JOptionPane.showMessageDialog(null, "La cotizacion no pudo ser procesada: no se pudo insertar el evento", "Resultado", JOptionPane.ERROR_MESSAGE);
            }
        } else {
            JOptionPane.showMessageDialog(null, "La cotizacion no pudo ser procesada: no se pudo insertar el cliente", "Resultado", JOptionPane.ERROR_MESSAGE);
        }
    }

    private void insertarEventoCotizacion() {

        boolean resultEvento = this.insertarEvento();
        if (resultEvento) {
            boolean resultCotizacion = this.insertarCotizacion();
            if (resultCotizacion) {
                JOptionPane.showMessageDialog(null, "La cotizacion ha sido procesada con Exito", "Resultado", JOptionPane.INFORMATION_MESSAGE);
            } else {
                this.borrarEvento();
                JOptionPane.showMessageDialog(null, "La cotizacion no pudo ser procesada", "Resultado", JOptionPane.ERROR_MESSAGE);
            }
        } else {
            JOptionPane.showMessageDialog(null, "La cotizacion no pudo ser procesada: no se pudo insertar el evento", "Resultado", JOptionPane.ERROR_MESSAGE);
        }

    }

    private void borrarCliente() {
        try {
            controlClientePart = new ControlClienteParticular();
            List<ClienteParticular> particulares = controlClientePart.consultarClienteParticular();
            controlClienteComp = new ControlClienteCompania();
            List<ClienteCompania> companias = controlClienteComp.consultarClienteCompania();

            if (radioCedula.isSelected()) {
                Integer Cedula = Integer.parseInt(clienteCed.getText().toString());
                for (int i = 0; i < particulares.size(); i++) {
                    if (particulares.get(i).getCedula().equals(Cedula)) {
                        controlClientePart.eliminarClienteParticular(particulares.get(i));
                    }
                }
            }

            if (radioRif.isSelected()) {
                String Rif = clienteRif.getText();
                for (int i = 0; i < companias.size(); i++) {
                    if (companias.get(i).getRif().equals(Rif)) {
                        controlClienteComp.eliminarClienteCompania(companias.get(i));
                    }
                }
            }

        } catch (IOException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    private void borrarEvento() {
        try {
            controlEvento = new ControlEvento();
            List<Evento> eventos = controlEvento.consultarEventos();
            Integer idUltimoEvento = eventos.get(eventos.size() - 1).getIdEvento();

            for (int i = 0; i < eventos.size(); i++) {
                if (eventos.get(i).getIdEvento().equals(idUltimoEvento)) {
                    controlEvento.eliminarEvento(eventos.get(i));
                }
            }

        } catch (IOException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    private void cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarActionPerformed
        Informacion info = new Informacion();
        info.setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_cancelarActionPerformed

    private void tablaCotizacion1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tablaCotizacion1KeyPressed
        this.calcularMontoTotal(tablaCotizacion1);
    }//GEN-LAST:event_tablaCotizacion1KeyPressed

    private void tablaCotizacion1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaCotizacion1MouseClicked
        this.calcularMontoTotal(tablaCotizacion1);
    }//GEN-LAST:event_tablaCotizacion1MouseClicked

    private void tablaCotizacion2KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tablaCotizacion2KeyPressed
        this.calcularMontoTotal(tablaCotizacion2);
    }//GEN-LAST:event_tablaCotizacion2KeyPressed

    private void tablaCotizacion2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaCotizacion2MouseClicked
        this.calcularMontoTotal(tablaCotizacion2);
    }//GEN-LAST:event_tablaCotizacion2MouseClicked

    private void tablaCotizacion3KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tablaCotizacion3KeyPressed
        this.calcularMontoTotal(tablaCotizacion3);
    }//GEN-LAST:event_tablaCotizacion3KeyPressed

    private void tablaCotizacion3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaCotizacion3MouseClicked
        this.calcularMontoTotal(tablaCotizacion3);
    }//GEN-LAST:event_tablaCotizacion3MouseClicked

    private void tablaCotizacion4KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tablaCotizacion4KeyPressed
        this.calcularMontoTotal(tablaCotizacion4);
    }//GEN-LAST:event_tablaCotizacion4KeyPressed

    private void tablaCotizacion4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaCotizacion4MouseClicked
        this.calcularMontoTotal(tablaCotizacion4);
    }//GEN-LAST:event_tablaCotizacion4MouseClicked

    private void tablaCotizacion5KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tablaCotizacion5KeyPressed
        this.calcularMontoTotal(tablaCotizacion5);
    }//GEN-LAST:event_tablaCotizacion5KeyPressed

    private void tablaCotizacion5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaCotizacion5MouseClicked
        this.calcularMontoTotal(tablaCotizacion5);
    }//GEN-LAST:event_tablaCotizacion5MouseClicked

    private void tablaCotizacion6KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tablaCotizacion6KeyPressed
        this.calcularMontoTotal(tablaCotizacion6);
    }//GEN-LAST:event_tablaCotizacion6KeyPressed

    private void tablaCotizacion6MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaCotizacion6MouseClicked
        this.calcularMontoTotal(tablaCotizacion6);
    }//GEN-LAST:event_tablaCotizacion6MouseClicked

    private void tablaCotizacion7KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tablaCotizacion7KeyPressed
        this.calcularMontoTotal(tablaCotizacion7);
    }//GEN-LAST:event_tablaCotizacion7KeyPressed

    private void tablaCotizacion7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaCotizacion7MouseClicked
        this.calcularMontoTotal(tablaCotizacion7);
    }//GEN-LAST:event_tablaCotizacion7MouseClicked

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        try {
            List<Insumo> insumos = this.consultarInsumos();
            this.cargarTablaCotizaciones(insumos, tablaCotizacion, "festejos");
            this.cargarTablaCotizaciones(insumos, tablaCotizacion1, "recreacion");
            this.cargarTablaCotizaciones(insumos, tablaCotizacion2, "servicios");
            this.cargarTablaCotizaciones(insumos, tablaCotizacion3, "decoracion");
            this.cargarTablaCotizaciones(insumos, tablaCotizacion4, "comestibles");
            this.cargarTablaCotizaciones(insumos, tablaCotizacion5, "carritos de consumo");
            this.cargarTablaCotizaciones(insumos, tablaCotizacion6, "pasapalos");
            this.cargarTablaCotizaciones(insumos, tablaCotizacion7, "transporte");
            this.redimensionarTabla();

            clienteCed.setText("");
            clienteRif.setText("");
            nombre.setText("");
            apellido.setText("");
            direccion.setText("");
            telefono.setText("");
            fechaEvento.setDate(null);
            color.setText("");
            motivo.setText("");
            horaInicioEvento.setSelectedItem("00:00:00");
            horaFinEvento.setSelectedItem("00:00:00");
            cedulaEjecutivo.setSelectedIndex(0);
            subtotal.setText("0.0");
            iva.setText("0.0");
            deposito.setText("0.0");
            total.setText("0.0");
            abono.setText("0.0");
            saldo.setText("0.0");

        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        try {
            List<Insumo> insumos = this.consultarInsumos();
            this.cargarTablaCotizaciones(insumos, tablaCotizacion, "festejos");
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        try {
            List<Insumo> insumos = this.consultarInsumos();
            this.cargarTablaCotizaciones(insumos, tablaCotizacion1, "recreacion");
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        try {
            List<Insumo> insumos = this.consultarInsumos();
            this.cargarTablaCotizaciones(insumos, tablaCotizacion2, "servicios");
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        try {
            List<Insumo> insumos = this.consultarInsumos();
            this.cargarTablaCotizaciones(insumos, tablaCotizacion3, "decoracion");
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        try {
            List<Insumo> insumos = this.consultarInsumos();
            this.cargarTablaCotizaciones(insumos, tablaCotizacion4, "comestibles");
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        try {
            List<Insumo> insumos = this.consultarInsumos();
            this.cargarTablaCotizaciones(insumos, tablaCotizacion5, "carritos de consumo");
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        try {
            List<Insumo> insumos = this.consultarInsumos();
            this.cargarTablaCotizaciones(insumos, tablaCotizacion6, "pasapalos");
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        try {
            List<Insumo> insumos = this.consultarInsumos();
            this.cargarTablaCotizaciones(insumos, tablaCotizacion7, "transporte");
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton9ActionPerformed

    private void clienteCedKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_clienteCedKeyPressed
}//GEN-LAST:event_clienteCedKeyPressed

    private void clienteRifActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clienteRifActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_clienteRifActionPerformed

    private void radioCedulaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioCedulaActionPerformed
        if (radioCedula.isSelected()) {
            jLabel14.setEnabled(false);
            clienteRif.setEnabled(false);
            jLabel15.setEnabled(true);
            clienteCed.setEnabled(true);
            jLabel2.setEnabled(true);
            apellido.setEnabled(true);

            clienteRif.setText("");
            nombre.setText("");
            direccion.setText("");
            telefono.setText("");

            jLabel75.setEnabled(true);
            jComboBoxSexo.setEnabled(true);
            jLabel76.setEnabled(true);
            jDateChooserNac.setEnabled(true);

            checkLista.setSelected(false);
            checkLista.setEnabled(false);
            listaCotizaciones.setEnabled(false);
            if (listaCotizaciones.getItemCount() > 0) {
                listaCotizaciones.removeAll();
            }
        }
}//GEN-LAST:event_radioCedulaActionPerformed

    private void radioRifActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioRifActionPerformed
        if (radioRif.isSelected()) {
            jLabel15.setEnabled(false);
            clienteCed.setEnabled(false);
            jLabel14.setEnabled(true);
            clienteRif.setEnabled(true);
            jLabel2.setEnabled(false);
            apellido.setEnabled(false);

            clienteCed.setText("");
            nombre.setText("");
            apellido.setText("");
            direccion.setText("");
            telefono.setText("");

            jLabel75.setEnabled(false);
            jComboBoxSexo.setEnabled(false);
            jLabel76.setEnabled(false);
            jDateChooserNac.setDate(null);
            jDateChooserNac.setEnabled(false);

            checkLista.setSelected(false);
            checkLista.setEnabled(false);
            listaCotizaciones.setEnabled(false);
            if (listaCotizaciones.getItemCount() > 0) {
                listaCotizaciones.removeAll();
            }
        }
}//GEN-LAST:event_radioRifActionPerformed

    private void clienteCedKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_clienteCedKeyTyped
    }//GEN-LAST:event_clienteCedKeyTyped

    private void clienteCedKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_clienteCedKeyReleased
        if (radioCedula.isSelected()) {
            if (!clienteCed.getText().equals("")) {
                this.jLabelCOT.setVisible(false);
                this.jLabelCOT2.setVisible(false);
                this.verificarCliente();
            }
        }
    }//GEN-LAST:event_clienteCedKeyReleased

    private void clienteRifKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_clienteRifKeyReleased
        if (radioRif.isSelected()) {
            if (!clienteRif.getText().equals("")) {
                this.jLabelCOT.setVisible(false);
                this.jLabelCOT2.setVisible(false);
                this.verificarClienteCompania();
            }
        }
    }//GEN-LAST:event_clienteRifKeyReleased

    private void checkListaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkListaActionPerformed
        if (checkLista.isSelected()) {
            this.listaCotizaciones.setEnabled(true);
        } else {
            try {
                this.listaCotizaciones.deselect(this.listaCotizaciones.getSelectedIndex());
                this.listaCotizaciones.setEnabled(false);
                this.jLabelCOT.setVisible(false);
                this.jLabelCOT2.setVisible(false);
                List<Insumo> insumos = this.consultarInsumos();
                this.cargarTablaCotizaciones(insumos);

                fechaEvento.setDate(null);
                color.setText("");
                motivo.setText("");
                horaInicioEvento.setSelectedItem("00:00:00");
                horaFinEvento.setSelectedItem("00:00:00");
                cedulaEjecutivo.setSelectedIndex(0);
                subtotal.setText("0.0");
                iva.setText("0.0");
                deposito.setText("0.0");
                total.setText("0.0");
                abono.setText("0.0");
                saldo.setText("0.0");
            } catch (SQLException ex) {
                Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_checkListaActionPerformed

    private void listaCotizacionesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listaCotizacionesMouseClicked
        try {
            if (listaCotizaciones.isEnabled()) {
                controlCotizacion = new ControlCotizacion();
                List<Cotizacion> cotizaciones = controlCotizacion.consultarCotizaciones();
                controlEvento = new ControlEvento();
                List<Evento> eventos = controlEvento.consultarEventos();
                controlEmpleado = new ControlEmpleado();
                List<Empleado> ejecutivos = controlEmpleado.consultarEjecutivos();
                String[] valorLista = listaCotizaciones.getSelectedItem().toString().split(", ");
                Integer idCotizacion = Integer.parseInt(valorLista[0]);

                for (Cotizacion cot : cotizaciones) {
                    if (cot.getIdCotizacion().equals(idCotizacion)) {
                        if (cot.getEstatus().equals("A")) {
                            this.jLabelCOT2.setText("APROBADA");
                            this.jLabelCOT.setVisible(true);
                            this.jLabelCOT2.setVisible(true);
                            this.jLabelCOT2.setForeground(Color.GREEN);
                        } else if (cot.getEstatus().equals("I")) {
                            this.jLabelCOT2.setText("INICIAL");
                            this.jLabelCOT.setVisible(true);
                            this.jLabelCOT2.setVisible(true);
                            this.jLabelCOT2.setForeground(Color.ORANGE);
                        } else if (cot.getEstatus().equals("R")) {
                            this.jLabelCOT2.setText("RECHAZADA");
                            this.jLabelCOT.setVisible(true);
                            this.jLabelCOT2.setVisible(true);
                            this.jLabelCOT2.setForeground(Color.RED);
                        }
                        for (Evento ev : eventos) {
                            if (cot.getEventoIdEvento().equals(ev.getIdEvento())) {
                                fechaEvento.setDate(ev.getFecha());
                                color.setText(cot.getColor());
                                motivo.setText(ev.getDescripcion());
                                jTextFieldLugar.setText(ev.getLugar());
                                horaInicioEvento.setSelectedItem(ev.getHoraInicio().toString());
                                horaFinEvento.setSelectedItem(ev.getHoraFin().toString());
                                for (Empleado ej : ejecutivos) {
                                    if (ej.getCedula().equals(ev.getEjecutivoCedula())) {
                                        cedulaEjecutivo.setSelectedItem(ej.getCedula() + ", " + ej.getNombre() + " " + ej.getApellido());
                                    }
                                }

                            }
                        }
                    }
                }
                List<Insumo> insumos = this.consultarInsumos();
                this.cargarInsumosCot(insumos);
            //this.cargarTablaInsumos();
            }
        } catch (IOException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_listaCotizacionesMouseClicked

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        String[] valor = cedulaEjecutivo.getSelectedItem().toString().split(", ");
        Integer cedulaE = Integer.parseInt(valor[0]);
        DisponibilidadEjecutivo de = new DisponibilidadEjecutivo(cedulaE);
        de.setVisible(true);
    }//GEN-LAST:event_jButton10ActionPerformed

    private void verificarCliente() {
        try {
            controlCotizacion = new ControlCotizacion();
            List<Cotizacion> cotizaciones = controlCotizacion.consultarCotizaciones();

            controlEvento = new ControlEvento();
            List<Evento> eventos = controlEvento.consultarEventos();

            controlClientePart = new ControlClienteParticular();
            List<ClienteParticular> particulares = controlClientePart.consultarClienteParticular();

            particular:
            for (int i = 0; i < particulares.size(); i++) {
                if (particulares.get(i).getCedula().equals(Integer.parseInt(clienteCed.getText().toString()))) {
                    nombre.setText(particulares.get(i).getNombre());
                    apellido.setText(particulares.get(i).getApellido());
                    direccion.setText(particulares.get(i).getDireccion());
                    telefono.setText(particulares.get(i).getTelefono());
                    jComboBoxSexo.setSelectedItem(particulares.get(i).getSexo());
                    jDateChooserNac.setDate(particulares.get(i).getFechaNacimiento());

                    for (int j = 0; j < cotizaciones.size(); j++) {
                        if (cotizaciones.get(j).getClienteParticularCedula().equals(particulares.get(i).getCedula())) {
                            checkLista.setEnabled(true);
                            for (int k = 0; k < eventos.size(); k++) {
                                if (eventos.get(k).getIdEvento().equals(cotizaciones.get(j).getEventoIdEvento())) {
                                     this.listaCotizaciones.add(cotizaciones.get(j).getIdCotizacion().toString() + ", " + cotizaciones.get(j).getFecha().toString() + ", Evento: " + eventos.get(k).getDescripcion() + ", " + eventos.get(k).getFecha().toString());
                                }
                            }
                        }
                    }

                    break particular;
                } else {
                    nombre.setText("");
                    apellido.setText("");
                    direccion.setText("");
                    telefono.setText("");
                    jTextFieldLugar.setText("");
                    checkLista.setSelected(false);
                    checkLista.setEnabled(false);
                    jComboBoxSexo.setSelectedItem("F");
                    jDateChooserNac.setDate(null);
                    listaCotizaciones.setEnabled(false);
                    if (listaCotizaciones.getItemCount() > 0) {
                        listaCotizaciones.removeAll();
                    }
                }
            }

        } catch (IOException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void verificarClienteCompania() {
        try {
            controlCotizacion = new ControlCotizacion();
            List<Cotizacion> cotizaciones = controlCotizacion.consultarCotizaciones();

            controlEvento = new ControlEvento();
            List<Evento> eventos = controlEvento.consultarEventos();

            controlClienteComp = new ControlClienteCompania();
            List<ClienteCompania> companias = controlClienteComp.consultarClienteCompania();

//            controlEmpleado = new ControlEmpleado();
//            List<Empleado> ejecutivos = controlEmpleado.consultarEjecutivos();

            compania:
            for (int i = 0; i < companias.size(); i++) {
                if (companias.get(i).getRif().equals(clienteRif.getText().toString())) {
                    nombre.setText(companias.get(i).getNombre());
                    direccion.setText(companias.get(i).getDireccion());
                    telefono.setText(companias.get(i).getTelefono());

                    for (int j = 0; j < cotizaciones.size(); j++) {
                        if (cotizaciones.get(j).getClienteCompaniaRif().equals(companias.get(i).getRif())) {
                            checkLista.setEnabled(true);
                            for (int k = 0; k < eventos.size(); k++) {
                                if (eventos.get(k).getIdEvento().equals(cotizaciones.get(j).getEventoIdEvento())) {
                                         this.listaCotizaciones.add(cotizaciones.get(j).getIdCotizacion().toString() + ", " + cotizaciones.get(j).getFecha().toString() + ", Evento: " + eventos.get(k).getDescripcion() + ", " + eventos.get(k).getFecha().toString());
                                    
                                }
                            }
                        }
                    }
                    break compania;
                } else {
                    this.nombre.setText("");
                    this.direccion.setText("");
                    this.telefono.setText("");
                    jTextFieldLugar.setText("");
                    this.checkLista.setSelected(false);
                    this.checkLista.setEnabled(false);
                    this.listaCotizaciones.setEnabled(false);
                    if (this.listaCotizaciones.getItemCount() > 0) {
                        this.listaCotizaciones.removeAll();
                    }
                    this.fechaEvento.setDate(null);
                    this.color.setText("");
                    this.motivo.setText("");
                    this.horaInicioEvento.setSelectedItem("00:00:00");
                    this.horaFinEvento.setSelectedItem("00:00:00");
                }
            }

        } catch (IOException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private boolean existeCliente() {
        boolean resultado = false;
        try {

            if (radioCedula.isSelected()) {
                controlClientePart = new ControlClienteParticular();
                List<ClienteParticular> particulares = controlClientePart.consultarClienteParticular();

                for (int i = 0; i < particulares.size(); i++) {
                    if (particulares.get(i).getCedula().equals(Integer.parseInt(clienteCed.getText()))) {
                        resultado = true;
                        return resultado;
                    } else {
                        if (i == particulares.size() - 1) {
                            resultado = false;
                            return resultado;
                        }
                    }
                }
            }

            if (radioRif.isSelected()) {
                controlClienteComp = new ControlClienteCompania();
                List<ClienteCompania> companias = controlClienteComp.consultarClienteCompania();

                for (int i = 0; i < companias.size(); i++) {
                    if (companias.get(i).getRif().equals(clienteRif.getText().toString())) {
                        resultado = true;
                        return resultado;
                    } else {
                        if (i == companias.size() - 1) {
                            resultado = false;
                            return resultado;
                        }
                    }
                }

            }
        } catch (IOException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
        return resultado;
    }

    private void validarCampos() {
        CampoNumerico campo = new CampoNumerico();
        campo.validarCampo(telefono);
        campo.validarCampo(clienteCed);
    }

    private void cargarTablaCotizaciones(List<Insumo> insumos) throws SQLException {
        this.cargarTablaCotizaciones(insumos, tablaCotizacion, "festejos");
        this.cargarTablaCotizaciones(insumos, tablaCotizacion1, "recreacion");
        this.cargarTablaCotizaciones(insumos, tablaCotizacion2, "servicios");
        this.cargarTablaCotizaciones(insumos, tablaCotizacion3, "decoracion");
        this.cargarTablaCotizaciones(insumos, tablaCotizacion4, "comestibles");
        this.cargarTablaCotizaciones(insumos, tablaCotizacion5, "carritos de consumo");
        this.cargarTablaCotizaciones(insumos, tablaCotizacion6, "pasapalos");
        this.cargarTablaCotizaciones(insumos, tablaCotizacion7, "transporte");
        this.redimensionarTabla();
    }

    private void cargarTablaInsumos() throws SQLException {
        this.cargarTablasInsumosClientes(tablaCotizacion, "festejos");
        this.cargarTablasInsumosClientes(tablaCotizacion1, "recreacion");
        this.cargarTablasInsumosClientes(tablaCotizacion2, "servicios");
        this.cargarTablasInsumosClientes(tablaCotizacion3, "decoracion");
        this.cargarTablasInsumosClientes(tablaCotizacion4, "comestibles");
        this.cargarTablasInsumosClientes(tablaCotizacion5, "carritos de consumo");
        this.cargarTablasInsumosClientes(tablaCotizacion6, "pasapalos");
        this.cargarTablasInsumosClientes(tablaCotizacion7, "transporte");
        this.redimensionarTabla();
    }

    /**
     * Carga la tabla de la cotizacion con los insumos que cotizo ese cliente en ese evento
     * @param tablaCotizacion
     * @param categoria
     * @throws java.sql.SQLException
     */
    private void cargarTablasInsumosClientes(JTable tablaCotizacion, String categoria) throws SQLException {

        String[] valorLista = listaCotizaciones.getSelectedItem().toString().split(", ");
        Integer idCotizacion = Integer.parseInt(valorLista[0]);
        List<ConsultaInsumos> consultaInsumos = this.consultarQueryInsumos();


        DefaultTableModel dm = new DefaultTableModel();
        dm.addColumn("Cantidad");
        dm.addColumn("Concepto");
        dm.addColumn("Costo Unitario");
        dm.addColumn("Total");

        for (ConsultaInsumos cons : consultaInsumos) {
            Vector tabla = new Vector();
            if (cons.getIdCotizacion().equals(idCotizacion)) {
                if (cons.getCategoria().equals(categoria)) {
                    tabla.addElement(cons.getCantidad());
                    tabla.addElement(cons.getCodigoInsumo() + ", " + cons.getConcepto());
                    tabla.addElement(cons.getCostoUnitario());
                    tabla.addElement(0.0);
                    dm.addRow(tabla);
                }
            }
        }
        tablaCotizacion.setModel(dm);
    }

    /**
     * Cargar las viejas con los nuevos insumos
     * @param insumos
     * @param tablaCotizacion
     * @param categoria
     */
    private void cargarInsumosCot(List<Insumo> insumos) {
        try {
            this.cargarTablaViejasCotizaciones(insumos, tablaCotizacion, "festejos");
            this.cargarTablaViejasCotizaciones(insumos, tablaCotizacion1, "recreacion");
            this.cargarTablaViejasCotizaciones(insumos, tablaCotizacion2, "servicios");
            this.cargarTablaViejasCotizaciones(insumos, tablaCotizacion3, "decoracion");
            this.cargarTablaViejasCotizaciones(insumos, tablaCotizacion4, "comestibles");
            this.cargarTablaViejasCotizaciones(insumos, tablaCotizacion5, "carritos de consumo");
            this.cargarTablaViejasCotizaciones(insumos, tablaCotizacion6, "pasapalos");
            this.cargarTablaViejasCotizaciones(insumos, tablaCotizacion7, "transporte");
            this.redimensionarTabla();
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void cargarTablaViejasCotizaciones(List<Insumo> insumos, JTable tablaCotizacion, String categoria) throws SQLException {
        List<Categoria> categorias = this.consultarCategorias();
        List<InsumoInventario> insumoInventarios = this.consultarInsumoInventarios();
        DefaultTableModel dm = new DefaultTableModel();

        String[] valorLista = listaCotizaciones.getSelectedItem().toString().split(", ");
        Integer idCotizacion = Integer.parseInt(valorLista[0]);
        List<ConsultaInsumos> consultaInsumos = this.consultarQueryInsumos();

        dm.addColumn("Cantidad");
        dm.addColumn("Concepto");
        dm.addColumn("Costo Unitario");
        dm.addColumn("Total");

        for (ConsultaInsumos cons : consultaInsumos) {
            if (cons.getIdCotizacion().equals(idCotizacion)) {
                if (cons.getCategoria().equals(categoria)) {
                    Vector tabla = new Vector();
                    tabla.addElement(cons.getCantidad());
                    tabla.addElement(cons.getCodigoInsumo() + ", " + cons.getConcepto());
                    tabla.addElement(cons.getCostoUnitario());
                    tabla.addElement(0.0);
                    dm.addRow(tabla);
                }
            }
        }

        for (Categoria cat : categorias) {
            Integer Id = cat.getidCATEGORIA();
            for (Insumo ins : insumos) {
                Integer idInsumo = ins.getIdINSUMO();
                if (ins.getidCATEGORIA().equals(Id)) {
                    for (InsumoInventario insInv : insumoInventarios) {
                        if (insInv.getINSUMO_idINSUMO().equals(idInsumo)) {
                            if (cat.getNombre().equals(categoria)) {
                                Vector tabla = new Vector();
                                tabla.addElement(0);
                                tabla.addElement(ins.getIdINSUMO() + ", " + ins.getConcepto());
                                tabla.addElement(insInv.getCostoUnitario());
                                tabla.addElement(0.0);
                                dm.addRow(tabla);
                            }
                        }
                    }
                }
            }
        }
        tablaCotizacion.setModel(dm);
    }

    private void cargarTablaCotizaciones(List<Insumo> insumos, JTable tablaCotizacion, String categoria) throws SQLException {
        List<Categoria> categorias = this.consultarCategorias();
        List<InsumoInventario> insumoInventarios = this.consultarInsumoInventarios();
        DefaultTableModel dm = new DefaultTableModel();

        //dm.addColumn("Categoria");
        dm.addColumn("Cantidad");
        dm.addColumn("Concepto");
        dm.addColumn("Costo Unitario");
        dm.addColumn("Total");

        for (int i = 0; i < categorias.size(); i++) {
            Integer Id = categorias.get(i).getidCATEGORIA();

            for (int j = 0; j < insumos.size(); j++) {
                Integer idInsumo = insumos.get(j).getIdINSUMO();
                if (insumos.get(j).getidCATEGORIA().equals(Id)) {
                    for (int k = 0; k < insumoInventarios.size(); k++) {
                        if (insumoInventarios.get(k).getINSUMO_idINSUMO().equals(idInsumo)) {
                            //System.out.println(insumos.get(j).getConcepto()+" "+insumoInventarios.get(k).getCostoUnitario()+" "+insumoInventarios.get(k).getINSUMO_idINSUMO());
                            if (categorias.get(i).getNombre().equals(categoria)) {
                                Vector tabla = new Vector();
                                tabla.addElement(0);
                                tabla.addElement(insumos.get(j).getIdINSUMO() + ", " + insumos.get(j).getConcepto());
                                tabla.addElement(insumoInventarios.get(k).getCostoUnitario());
                                tabla.addElement(0.0);

                                dm.addRow(tabla);
                            }
                        }
                    }
                }
            }
        }
        tablaCotizacion.setModel(dm);
    }

    private List<ConsultaInsumos> consultarQueryInsumos() throws SQLException {
        List<ConsultaInsumos> insumos = null;
        try {
            controlConsultaInsumos = new ControlConsultaInsumos();
            insumos = controlConsultaInsumos.consultarInsumos();
            return insumos;

        } catch (IOException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        }
        return insumos;
    }

    private List<Uso> consultarUso() throws SQLException {
        List<Uso> usos = null;
        try {
            controlUso = new ControlUso();
            usos = controlUso.consultarUso();
            return usos;

        } catch (IOException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        }
        return usos;
    }

    private List<Cotizacion> consultarCotizaciones() throws SQLException {
        List<Cotizacion> cotizaciones = null;
        try {
            controlCotizacion = new ControlCotizacion();
            cotizaciones = controlCotizacion.consultarCotizaciones();
            return cotizaciones;

        } catch (IOException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        }
        return cotizaciones;
    }

    private List<Insumo> consultarInsumos() throws SQLException {
        List<Insumo> insumos = null;
        try {
            controlInsumo = new ControlInsumo();
            insumos = controlInsumo.consultarInsumo();
            return insumos;

        } catch (IOException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        }
        return insumos;
    }

    private List<Categoria> consultarCategorias() throws SQLException {
        List<Categoria> categorias = null;
        try {
            controlCategoria = new ControlCategoria();
            categorias = controlCategoria.consultarCategoria();
            return categorias;

        } catch (IOException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        }
        return categorias;
    }

    private List<InsumoInventario> consultarInsumoInventarios() throws SQLException {
        List<InsumoInventario> insumoInventarios = null;
        try {
            controlInsumoInventario = new ControlInsumoInventario();
            insumoInventarios = controlInsumoInventario.consultarInsumoInventario();
            return insumoInventarios;

        } catch (IOException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        }
        return insumoInventarios;
    }

    private void calcularMontoTotal(JTable tablaCotizacion) {
        for (int i = 0; i < tablaCotizacion.getRowCount(); i++) {
            Time horaI = Time.valueOf(horaInicioEvento.getSelectedItem().toString());
            Time horaF = Time.valueOf(horaFinEvento.getSelectedItem().toString());
            long diferencia = horaF.getTime() - horaI.getTime();
            long horasD = diferencia / (1000 * 60 * 60);
            Integer valor1 = Integer.parseInt(tablaCotizacion.getValueAt(i, 0).toString());
            double valor2 = Double.valueOf(tablaCotizacion.getValueAt(i, 2).toString());
            double resultado = 0;

            String[] cadena = tablaCotizacion.getValueAt(i, 1).toString().split(", ");
            String concepto = cadena[1];
            if (concepto.equals("Recreadoras") || concepto.equals("Payasitas") || concepto.equals("Display(equipo basico infantil)") || concepto.equals("Display") || concepto.equals("Colchones") || concepto.equals("Cama elastica") || concepto.equals("Grupo musical en vivo") || concepto.equals("Hora loca(material)") || concepto.equals("Despedida de soltero(a) striper") || concepto.equals("Zanqueros,samba,tambores,garotas,iluminacion")) {

                resultado = valor1 * valor2 * horasD;
            } else {
                resultado = valor1 * valor2;
            }
            tablaCotizacion.setValueAt(resultado, i, 3);
        }
        this.calcularSubTotal();
        this.calcularIva();
        this.calcularDeposito();
        this.calcularTotal();
        this.calcularAbono();
        this.calcularSaldo();
    }

    private void calcularSubTotal() {
        double acum = 0.0;
        for (int i = 0; i < tablaCotizacion.getRowCount(); i++) {
            acum = acum + Double.valueOf(tablaCotizacion.getValueAt(i, 3).toString());
            subtotal.setText(Double.toString(acum));
        }
        for (int i = 0; i < tablaCotizacion1.getRowCount(); i++) {
            acum = acum + Double.valueOf(tablaCotizacion1.getValueAt(i, 3).toString());
            subtotal.setText(Double.toString(acum));
        }
        for (int i = 0; i < tablaCotizacion2.getRowCount(); i++) {
            acum = acum + Double.valueOf(tablaCotizacion2.getValueAt(i, 3).toString());
            subtotal.setText(Double.toString(acum));
        }
        for (int i = 0; i < tablaCotizacion3.getRowCount(); i++) {
            acum = acum + Double.valueOf(tablaCotizacion3.getValueAt(i, 3).toString());
            subtotal.setText(Double.toString(acum));
        }
        for (int i = 0; i < tablaCotizacion4.getRowCount(); i++) {
            acum = acum + Double.valueOf(tablaCotizacion4.getValueAt(i, 3).toString());
            subtotal.setText(Double.toString(acum));
        }
        for (int i = 0; i < tablaCotizacion5.getRowCount(); i++) {
            acum = acum + Double.valueOf(tablaCotizacion5.getValueAt(i, 3).toString());
            subtotal.setText(Double.toString(acum));
        }
        for (int i = 0; i < tablaCotizacion6.getRowCount(); i++) {
            acum = acum + Double.valueOf(tablaCotizacion6.getValueAt(i, 3).toString());
            subtotal.setText(Double.toString(acum));
        }
        for (int i = 0; i < tablaCotizacion7.getRowCount(); i++) {
            acum = acum + Double.valueOf(tablaCotizacion7.getValueAt(i, 3).toString());
            subtotal.setText(Double.toString(acum));
        }
    }

    private void calcularIva() {
        double monto = Double.valueOf(subtotal.getText());
        double ivaValor = monto * 0.09;
        double resultado = this.redondear(ivaValor, 2);
        iva.setText(Double.toString(resultado));
    }

    private double redondear(double numero, int decimales) {
        return Math.round(numero * Math.pow(10, decimales)) / Math.pow(10, decimales);
    }

    private void calcularTotal() {
        double Subtotal = Double.valueOf(subtotal.getText().toString());
        double Iva = Double.valueOf(iva.getText().toString());
        double Deposito = Double.valueOf(deposito.getText().toString());
        double resultado = this.redondear(Subtotal + Iva + Deposito, 2);
        total.setText(Double.toString(resultado));
    }

    private void calcularAbono() {
        double Total = Double.valueOf(total.getText().toString());
        double Abono = Total * 0.5;
        double resultado = this.redondear(Abono, 2);
        abono.setText(Double.toString(resultado));
    }

    private void calcularSaldo() {
        double Total = Double.valueOf(total.getText().toString());
        double Abono = Double.valueOf(abono.getText().toString());
        double Saldo = this.redondear(Total - Abono, 2);
        saldo.setText(Double.toString(Saldo));
    }

    private void calcularDeposito() {
        double monto = Double.valueOf(subtotal.getText());
        double depValor = monto * 0.05;
        double resultado = this.redondear(depValor, 2);
        deposito.setText(Double.toString(resultado));
    }

    private boolean insertarCliente() {
        boolean flag = false;
        try {
            controlClientePart = new ControlClienteParticular();
            controlClienteComp = new ControlClienteCompania();

            if (radioCedula.isSelected()) {
                Integer Cedula = Integer.parseInt(clienteCed.getText());
                String Nombre = nombre.getText();
                String Apellido = apellido.getText();
                String Direccion = direccion.getText();
                String Telefono = telefono.getText();
                String sexo = jComboBoxSexo.getSelectedItem().toString();
                java.sql.Date fechaNac = new java.sql.Date(jDateChooserNac.getDate().getTime());

                ClienteParticular particular = new ClienteParticular(Cedula, Nombre, Apellido, Direccion, Telefono,fechaNac,sexo);
                flag = controlClientePart.agregarClienteParticular(particular);

                if (flag) {
                    controlEmpleadoClientePart = new ControlEmpleadoClientePart();
                    String[] arreglo = cedulaEjecutivo.getSelectedItem().toString().split(", ");
                    Integer CedulaEjecutivo = Integer.parseInt(arreglo[0]);
                    EmpleadoClientePart clientePart = new EmpleadoClientePart(Cedula, CedulaEjecutivo);

                    boolean resultado = controlEmpleadoClientePart.agregarEmpleadoClientePart(clientePart);
                }

                return flag;
            }

            if (radioRif.isSelected()) {
                String Rif = clienteRif.getText();
                String Nombre = nombre.getText();
                String Direccion = direccion.getText();
                String Telefono = telefono.getText();

                ClienteCompania compania = new ClienteCompania(Rif, Nombre, Direccion, Telefono);
                flag = controlClienteComp.agregarClienteCompania(compania);

                controlEmpleadoClienteComp = new ControlEmpleadoClienteComp();
                String[] arreglo = cedulaEjecutivo.getSelectedItem().toString().split(", ");
                Integer CedulaEjecutivo = Integer.parseInt(arreglo[0]);
                EmpleadoClienteComp clienteComp = new EmpleadoClienteComp(Rif, CedulaEjecutivo);

                boolean resultado = controlEmpleadoClienteComp.agregarEmpleadoClienteComp(clienteComp);

                return flag;
            }

        } catch (IOException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        }
        return (flag);
    }

    private boolean insertarEvento() {
        boolean flag = false;
        try {
            controlEvento = new ControlEvento();
            List<Evento> eventos = controlEvento.consultarEventos();
            java.sql.Date FechaEvento = new java.sql.Date(fechaEvento.getDate().getTime());
            String Descripcion = motivo.getText();
            Time horaInew = Time.valueOf(String.valueOf(horaInicioEvento.getSelectedItem()));
            Time horaFnew = Time.valueOf(String.valueOf(horaFinEvento.getSelectedItem()));
            java.sql.Date now = new java.sql.Date(System.currentTimeMillis());
            String[] ced = cedulaEjecutivo.getSelectedItem().toString().split(", ");
            Integer cedulaE = Integer.parseInt(ced[0]);
            String lugarE = jTextFieldLugar.getText();

            long diff = FechaEvento.getTime() - now.getTime();
            long dias = 0;
            if (FechaEvento.equals(now)) {
                dias = 0;
            } else {
                dias = (diff / (1000 * 60 * 60 * 24)) + 1;
            }

            if (FechaEvento.before(now) || FechaEvento.equals(now) || dias < 14) {
                JOptionPane.showMessageDialog(null, "La fecha seleccionada es invalida: \n" +
                        "No puede ser la actual o una pasada.\n" +
                        "El evento debe ser al menos dentro de 15 dias.", "Error", JOptionPane.ERROR_MESSAGE);
            } else {
                if (horaInew.getTime() == horaFnew.getTime()) {
                    JOptionPane.showMessageDialog(null, "La hora de Inicio no puede ser igual a la final", "Error", JOptionPane.ERROR_MESSAGE);

                } else {
                    busqueda:
                    for (int i = 0; i < eventos.size(); i++) {
                        Time horai = eventos.get(i).getHoraInicio();
                        Time horaf = eventos.get(i).getHoraFin();
                        Integer ejecutivo = eventos.get(i).getEjecutivoCedula();
                        Date fecha = eventos.get(i).getFecha();

                        if (cedulaE.equals(ejecutivo) && FechaEvento.toString().equals(fecha.toString())) {
                            if ((horaInew.equals(horai)) || (horaInew.equals(horaf)) || (horaFnew.equals(horai)) || (horaFnew.equals(horaf)) || (horaFnew.after(horai) && horaFnew.before(horaf)) || (horaInew.after(horai) && horaInew.before(horaf)) || (horaInew.before(horai) && horaFnew.after(horaf))) {
                                JOptionPane.showMessageDialog(aviso, "El ejecutivo no se encuentra disponible en esa fecha, en el horario indicado.\n" +
                                        "Estas son las soluciones:\n- Escoger un nuevo horario\n- Escoger ejecutivo diferente", "Nota", 1);
                                break busqueda;
                            } else {
                                if (i == eventos.size() - 1) {
                                    flag = this.insertarE(FechaEvento, Descripcion, lugarE, horaInew, horaFnew, cedulaE);
                                    return flag;
                                }
                            }
                        } else {
                            if (i == eventos.size() - 1) {
                                flag = this.insertarE(FechaEvento, Descripcion, lugarE, horaInew, horaFnew, cedulaE);
                                return flag;
                            }
                        }
                    }
                }
            }
            return flag;
        } catch (IOException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        }
        return flag;
    }

    private boolean estaHabilitadoEjecutivo(Integer cedula){
        boolean flag = false;
        try {
            controlEmpleado = new ControlEmpleado();
            List<Empleado> ejecutivos = controlEmpleado.consultarEjecutivos();
            for (Empleado eje : ejecutivos) {
                if (eje.getCedula().equals(cedula)) {
                    if (eje.isHabilitado().equals("s")) {
                        flag = true;
                        return flag;
                    }
                }
            }
        } catch (IOException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
        return flag;
    }

    private boolean insertarE(Date FechaEvento, String Descripcion,String Lugar, Time horaInew, Time horaFnew, Integer cedulaE) {
        Evento evento = new Evento(FechaEvento, Descripcion, Lugar, horaInew, horaFnew, cedulaE);
        boolean flag = controlEvento.agregarEvento(evento);
        return flag;
    }

    private boolean insertarCotizacion() {
        boolean flag = false;
        try {
            controlCotizacion = new ControlCotizacion();
            controlEvento = new ControlEvento();
            List<Evento> eventos = controlEvento.consultarEventos();
            List<Cotizacion> cotizaciones = controlCotizacion.consultarCotizaciones();

            java.text.SimpleDateFormat fmt = new java.text.SimpleDateFormat("yyyy-MM-dd");
            java.sql.Date now = new java.sql.Date(System.currentTimeMillis());

            String Estatus = "I";

            Date fechaActual = Date.valueOf(fmt.format(now));
            String Color = color.getText();
            Integer idUltimoEvento = eventos.get(eventos.size() - 1).getIdEvento();

            if (radioRif.isSelected()) {
                String rifCiaCot = clienteRif.getText();
                double montoTotal = Double.valueOf(total.getText().toString());
                Cotizacion cotizacionComp = new Cotizacion(Estatus, fechaActual, Color, montoTotal, idUltimoEvento, rifCiaCot, null);
                flag = controlCotizacion.agregarCotizacion(cotizacionComp);
                if(flag){
                    cotizaciones = controlCotizacion.consultarCotizaciones();
                    for (Cotizacion cotizacion : cotizaciones) {
                        if (cotizacion.getClienteCompaniaRif().equals(rifCiaCot)) {
                            checkLista.setEnabled(true);
                            for (Evento evento : eventos) {
                                if (evento.getIdEvento().equals(cotizacion.getEventoIdEvento())) {
                                        this.listaCotizaciones.add(cotizacion.getIdCotizacion().toString() + ", " + cotizacion.getFecha().toString() + ", Evento: " + evento.getDescripcion() + ", " + evento.getFecha().toString());
                                    
                                }
                            }
                        }
                    }
                }
                return flag;
            }

            if (radioCedula.isSelected()) {
                Integer cedParCot = Integer.valueOf(clienteCed.getText());
                double montoTotal = Double.valueOf(total.getText().toString());
                Cotizacion cotizacionComp = new Cotizacion(Estatus, fechaActual, Color, montoTotal, idUltimoEvento, null, cedParCot);
                flag = controlCotizacion.agregarCotizacion(cotizacionComp);
                if(flag){
                    cotizaciones = controlCotizacion.consultarCotizaciones();
                    for (Cotizacion cotizacion : cotizaciones) {
                        if (cotizacion.getClienteParticularCedula().equals(cedParCot)) {
                            checkLista.setEnabled(true);
                            for (Evento evento : eventos) {
                                if (evento.getIdEvento().equals(cotizacion.getEventoIdEvento())) {
                                        this.listaCotizaciones.add(cotizacion.getIdCotizacion().toString() + ", " + cotizacion.getFecha().toString() + ", Evento: " + evento.getDescripcion() + ", " + evento.getFecha().toString());
                                     
                                }
                            }
                        }
                    }
                }
                return flag;
            }

            return flag;
        } catch (IOException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        }
        return flag;
    }

    private boolean isCamposCompletos() {
        if (radioCedula.isSelected()) {
            if ((clienteCed.getText().equals("")) || (nombre.getText().equals("")) || (apellido.getText().equals("")) || (direccion.getText().equals("")) || (telefono.getText().equals("")) || (color.getText().equals("")) || (motivo.getText().equals(""))) {
                return false;
            } else {
                return true;
            }
        } else {
            if ((clienteRif.getText().equals("")) || (nombre.getText().equals("")) || (direccion.getText().equals("")) || (telefono.getText().equals("")) || (color.getText().equals("")) || (motivo.getText().equals(""))) {
                return false;
            } else {
                return true;
            }
        }
    }

    private boolean isCumpleCliente(){
        boolean flag = false;
        java.sql.Date now = new java.sql.Date(System.currentTimeMillis());
        java.sql.Date cumpleCliente = new java.sql.Date(jDateChooserNac.getDate().getTime());
        if(cumpleCliente.equals(now)){
            flag = true;
            System.out.println("El cliente esta de cumpleeee");
            return flag;
        }
        return flag;
    }

    private boolean isTablaVacia() {
        boolean flag = false;
        boolean result = this.isTablaVacia(tablaCotizacion);
        boolean result1 = this.isTablaVacia(tablaCotizacion1);
        boolean result2 = this.isTablaVacia(tablaCotizacion2);
        boolean result3 = this.isTablaVacia(tablaCotizacion3);
        boolean result4 = this.isTablaVacia(tablaCotizacion4);
        boolean result5 = this.isTablaVacia(tablaCotizacion5);
        boolean result6 = this.isTablaVacia(tablaCotizacion6);
        boolean result7 = this.isTablaVacia(tablaCotizacion7);

        if (result && result1 && result2 && result3 && result4 && result5 && result6 && result7) {
            flag = true;
            return flag;
        } else {
            if (!(result) || !(result1) || !(result2) || !(result3) || !(result4) || !(result5) || !(result6) || !(result7)) {
                flag = false;
                return flag;
            }
        }

        return flag;
    }

    private boolean isTablaVacia(JTable tablaCotizacion) {
        boolean flag = false;

        for (int i = 0; i < tablaCotizacion.getRowCount(); i++) {
            if (tablaCotizacion.getValueAt(i, 0).toString().equals("0")) {
                if (i == tablaCotizacion.getRowCount() - 1) {
                    flag = true;
                    return flag;
                }
            } else {
                flag = false;
                return flag;
            }
        }

        return flag;
    }

    private void cargarCedulasEjecutivos() {
        cedulaEjecutivo.setVisible(false);
        if (cedulaEjecutivo.isPopupVisible() != true) {
            cedulaEjecutivo.removeAllItems();
        }
        try {
            controlEmpleado = new ControlEmpleado();
            List<Empleado> ejecutivos = controlEmpleado.consultarEjecutivos();
            for (int i = 0; i < ejecutivos.size(); i++) {
                String Nombre = ejecutivos.get(i).getNombre() + " " + ejecutivos.get(i).getApellido();
                String Cedula = ejecutivos.get(i).getCedula().toString();
                if (ejecutivos.get(i).isHabilitado().equals("s")) {
                    cedulaEjecutivo.addItem(Cedula + ", " + Nombre);
                }
            }
        } catch (IOException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(InformacionSistema.class.getName()).log(Level.SEVERE, null, ex);
        }
        cedulaEjecutivo.setVisible(true);
    }

    private void redimensionarTabla() {
        this.redimensionarTabla(tablaCotizacion);
        this.redimensionarTabla(tablaCotizacion1);
        this.redimensionarTabla(tablaCotizacion2);
        this.redimensionarTabla(tablaCotizacion3);
        this.redimensionarTabla(tablaCotizacion4);
        this.redimensionarTabla(tablaCotizacion5);
        this.redimensionarTabla(tablaCotizacion6);
        this.redimensionarTabla(tablaCotizacion7);
    }

    private void redimensionarTabla(JTable tablaCotizacion) {
        TableColumn column = null;
        for (int i = 0; i < 4; i++) {
            column = tablaCotizacion.getColumnModel().getColumn(i);
            if (i == 1) {
                column.setPreferredWidth(135); //sport column is bigger
            } else {
                column.setPreferredWidth(50);
            }
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    new NuevaCotizacion().setVisible(true);
                } catch (SQLException ex) {
                    Logger.getLogger(NuevaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel abono;
    private javax.swing.JTextField apellido;
    private javax.swing.JMenu archivo;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroupEstatus;
    private javax.swing.JButton cancelar;
    private javax.swing.JComboBox cedulaEjecutivo;
    private javax.swing.JCheckBox checkLista;
    private javax.swing.JTextField clienteCed;
    private javax.swing.JTextField clienteRif;
    private javax.swing.JTextField color;
    private javax.swing.JLabel deposito;
    private javax.swing.JTextField direccion;
    private javax.swing.JMenuItem exit;
    private com.toedter.calendar.JDateChooser fechaEvento;
    private javax.swing.JComboBox horaFinEvento;
    private javax.swing.JComboBox horaInicioEvento;
    private javax.swing.JMenuItem informacionSistema;
    private javax.swing.JLabel iva;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JComboBox jComboBoxSexo;
    private com.toedter.calendar.JDateChooser jDateChooserNac;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel47;
    private javax.swing.JLabel jLabel48;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel51;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel75;
    private javax.swing.JLabel jLabel76;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelCOT;
    private javax.swing.JLabel jLabelCOT2;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField jTextFieldLugar;
    private java.awt.List listaCotizaciones;
    private javax.swing.JTextField motivo;
    private javax.swing.JTextField nombre;
    private javax.swing.JMenuItem nuevaCotizacion;
    private javax.swing.JButton procesar;
    private javax.swing.JRadioButton radioCedula;
    private javax.swing.JRadioButton radioRif;
    private javax.swing.JLabel saldo;
    private javax.swing.JLabel subtotal;
    private javax.swing.JTable tablaCotizacion;
    private javax.swing.JTable tablaCotizacion1;
    private javax.swing.JTable tablaCotizacion2;
    private javax.swing.JTable tablaCotizacion3;
    private javax.swing.JTable tablaCotizacion4;
    private javax.swing.JTable tablaCotizacion5;
    private javax.swing.JTable tablaCotizacion6;
    private javax.swing.JTable tablaCotizacion7;
    private javax.swing.JTextField telefono;
    private javax.swing.JLabel total;
    // End of variables declaration//GEN-END:variables
}
